package com.hbnu.net;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class TcpClientDemo1 {

    public static void main(String[] args) {
        //创建Socket，TCP连接需要指定目标地址和端口
        Socket socket = null;
        try {
            socket = new Socket("127.0.0.1",6666);

            OutputStream out = socket.getOutputStream();

            String content = "所爱隔山海，山海皆可平";
            out.write(content.getBytes());

            out.close();
            socket.close();

        } catch (IOException e) {
            e.printStackTrace();

        }
    }
}
